package acheng1314.cn.a3dbuild2.widgets;

import android.app.ProgressDialog;
import android.content.Context;

/**
 * Created by Administrator on 2016/10/5 0005.
 */

public class MyProgressDialog {

    private final ProgressDialog progressDialog;
    private final String title;
    private final String message;
    private final Context context;

    public MyProgressDialog(String title, String message, Context context) {
        this.title = title;
        this.message = message;
        this.context = context;


        progressDialog = new ProgressDialog(context);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setTitle(title);
        progressDialog.setMessage(message);
//        progressDialog.setIcon(android.support.v7.appcompat.R.drawable.notification_template_icon_bg);
        progressDialog.setCancelable(false);
        progressDialog.show();
    }

    public void show() {
        if (progressDialog == null) {
            //对话框不存在时候，应该创建对话框
            new MyProgressDialog(title, message, context);
        } else
            progressDialog.show();
    }

    public void dismiss() {
        if (null != progressDialog) {
            progressDialog.dismiss();
        }
    }

    public boolean isShowing() {
        return progressDialog.isShowing();
    }
}
